//菜单信息
const menuData = [
    {
        title: "仪表盘",
        href: "#/dashboard"
    },
    {
        title: "库存管理",
        submenu: [
            { title: "库存列表", href: "#/inventory/list" },
            { title: "库存调整", href: "#/inventory/adjustment" },
            { title: "库存调拨", href: "#/inventory/transfer" }
        ]
    },
    {
        title: "订单管理",
        submenu: [
            { title: "入库订单", href: "#/orders/inbound" },
            { title: "出库订单", href: "#/orders/outbound" },
            { title: "订单跟踪", href: "#/orders/tracking" }
        ]
    },
    {
        title: "用户管理",
        submenu: [
            { title: "用户列表", href: "#/users/list" },
            { title: "角色管理", href: "#/users/roles" }
        ]
    },
    {
        title: "报表统计",
        submenu: [
            { title: "库存报表", href: "#/reports/inventory" },
            { title: "订单报表", href: "#/reports/orders" }
        ]
    },
    {
        title: "系统设置",
        submenu: [
            { title: "仓库设置", href: "#/settings/warehouse" },
            { title: "系统参数", href: "#/settings/system" }
        ]
    },
    {
        title: "abc",
        submenu: [
            { title: "ABCE", href: "#/settings/warehouse1" },
            { title: "EFGH", href: "#/settings/warehouse2" }
        ]
    },
    {
        title: "qwer",
        submenu: [
            { title: "4321", href: "#/settings/warehouse3" },
            { title: "5432", href: "#/settings/warehouse4" }
        ]
    }
];

//从新对应router
let router = {
    "#/main" : "Component/Main/main.html",
    "#/Personalcenter/personalcenter": "Component/Personalcenter/personalcenter.html",
    "#/Accountsetting/accountsetting": "Component/Accountsetting/accountsetting.html"
};
let titles = {
    "#/main" : "首页",
    "#/Personalcenter/personalcenter":"个人中心",
    "#/Accountsetting/accountsetting" :"账户设置"
};
//反标题
let untitles = {

};

//菜单list
let menuList = [];

menuData.forEach(obj=>{
    if(obj.hasOwnProperty("href")){
        let str = obj.href.substring(2);
        router[obj.href] = `Component/${toUpper(str)}/${str.toLowerCase()}.html`;

        titles[obj.href] = obj.title;
    }else{
        if(!obj.submenu) return ;
        obj.submenu.forEach(item=>{
            let str = item.href.substring(2);
            let route = str.split("/");
            router[item.href] = `Component/${toUpper(route[0])}/${toUpper(route[1])}/${route[1].toLowerCase()}.html`
            titles[item.href] = item.title;
        })
    }
})

function toUpper(str){
    return str.at(0).toUpperCase() + str.substring(1).toLowerCase();
}
//反标题
Object.entries(titles).forEach(([k,v])=>{
    untitles[v] = k;
    menuList.push(v);
})
